using System;
using MySql.Data.MySqlClient;

namespace motte
{
	public class mteMyCnx
	{
		private MySqlConnection _idConnection;
		
		// Host
		protected string host
		{
        	get {return host;}
        	set {host = value;}
        }
		
		// Port
		protected int port
		{
        	get {return port;}
        	set {port = value;}
        }
		
		// User
		protected string user
		{
        	get {return user;}
        	set {user = value;}
        }
			
		// Password
		protected string password
		{
        	get {return password;}
        	set {password = value;}
        }

		// base name
		protected string baseName
		{
        	get {return baseName;}
        	set {baseName = value;}
        }
		
		protected bool pooling
		{
        	get {return pooling;}
        	set {pooling = value;}
        }		
		
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		//   					p r i v a t e   m e t o h d s
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		private void _initialize()
		{
			this._idConnection = new MySqlConnection();
			this.port = 3306;
			this.host = "";
			this.user = "";
			this.password = "";
			this.baseName = "";
			this.pooling = false;			
		}
		
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		//   					c o n s t r u c t o r s
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		public mteMyCnx ()
		{
			this._initialize();
		}
		
		public mteMyCnx (string host, int port, string user, string password, string baseName, bool pooling)
		{
			this._initialize();
			
			// set properties
			this.host = host;
			this.port = port;
			this.user = user;
			this.password = password;
			this.baseName = baseName;
			this.pooling = pooling;
		}
		
		public function connect()
		{
			// String connection
			MySqlConnectionStringBuilder cnxBuilder = new MySqlConnectionStringBuilder();
			cnxBuilder.Database = this.baseName;
			cnxBuilder.Server = this.host;
			cnxBuilder.Password = this.password;
			cnxBuilder.ConnectionProtocol = MySqlConnectionProtocol.Sockets;
			cnxBuilder.UserID = this.user;
			cnxBuilder.Pooling = this.pooling;
			cnxBuilder.Port = this.port;
			
			//return cnxBuilder.GetConnectionString(true);
			
		}
			
		
		
	}
}

